Dynamic array used as list DBE content

I'm new to DXL. I'm trying to write a script to add strings to a list box when a user types in an entry and clicks Add To Filters. Here is the farthest I've gotten.
 

string userInputs[]    //array to hold strings input by user
int position = 0
 
DB complexFilterDialog = create("Complex Filter", styleFixed|styleCentered|styleFloating)
DBE userInput = field(complexFilterDialog, "Object Text contains ", "", 12)
 
void AppendToFilters(DBE calledfrom) {
        get(userInput)
        // Not sure what to do here
}
 
 
 
beside(complexFilterDialog)
 
DBE addUserInput = button(complexFilterDialog, "Add To Filters", AppendToFilters)
DBE userInputList = list(complexFilterDialog, "Filters", 5, userInputs)
 
show complexFilterDialog

 


I see that the list DBE uses string[], and I would like to be able to use dynamic allocation to grow the array as more strings are added.

Any guidance is appreciated.

 


CLCora - Thu Nov 18 14:07:44 EST 2010

Re: Dynamic array used as list DBE content
SystemAdmin - Fri Nov 19 02:50:30 EST 2010

You can use an empty array to create your list DBE and then afterwards use the insert function to create the items in the DBE (maybe simultaneously adding them to a skip list for later use).
 

// Empty array for creating the list DBE
string userInputs[] = {}
int position = 0
 
DB complexFilterDialog = create("Complex Filter", styleFixed|styleCentered|styleFloating)
DBE userInput = field(complexFilterDialog, "Object Text contains ", "", 12)
DBE userInputList = null
DBE addUserInput = null
 
void AppendToFilters(DBE calledfrom) 
{
    string Input = get(userInput)
    // insert function for inputting elements into list
    insert(userInputList, position, Input)
    // increase the row marker
    position++
}
   
beside(complexFilterDialog)
 
addUserInput = button(complexFilterDialog, "Add To Filters", AppendToFilters)
userInputList = list(complexFilterDialog, "Filters", 5, userInputs)
 
show complexFilterDialog

Re: Dynamic array used as list DBE content
CLCora - Mon Dec 06 08:48:36 EST 2010

SystemAdmin - Fri Nov 19 02:50:30 EST 2010

You can use an empty array to create your list DBE and then afterwards use the insert function to create the items in the DBE (maybe simultaneously adding them to a skip list for later use).
 

// Empty array for creating the list DBE
string userInputs[] = {}
int position = 0
 
DB complexFilterDialog = create("Complex Filter", styleFixed|styleCentered|styleFloating)
DBE userInput = field(complexFilterDialog, "Object Text contains ", "", 12)
DBE userInputList = null
DBE addUserInput = null
 
void AppendToFilters(DBE calledfrom) 
{
    string Input = get(userInput)
    // insert function for inputting elements into list
    insert(userInputList, position, Input)
    // increase the row marker
    position++
}
   
beside(complexFilterDialog)
 
addUserInput = button(complexFilterDialog, "Add To Filters", AppendToFilters)
userInputList = list(complexFilterDialog, "Filters", 5, userInputs)
 
show complexFilterDialog

That's perfect, thank you Pekka.

Also, are there any built in sorting functions for the list DBE in DXL? For example, alphabetical sorting? If not, are there for the base string array used? I know I can create a sorting function, but if one exists it would clean up the code. Thanks!